mp: sort flb_record_accessor by a number of subkeys(#5546)#5590
mp: sort flb_record_accessor by a number of subkeys(#5546)#5590edsiper merged 6 commits intofluent:masterfrom
Conversation
|
Hmm, mk_list API can't add new value to head of the list. |
|
It is ready to review. |
|
@nokute78 pls submit mk_list changes directly to monkey, we will do the merge back. |
|
@edsiper I sent a patch monkey/monkey#371. |
|
monkey/monkey#371 was updated. |
| return -1; | ||
| } | ||
|
|
||
| return mk_list_size(rp->key->subkeys); |
There was a problem hiding this comment.
Beware of mk_list_size, it iterates the entire list in order to calculate the size each time. At this point I think we might just waste 8 bytes per node and add a counter that's only used in the head node but I haven't properly assessed the impact of it yet.
There was a problem hiding this comment.
I'm glad monkey API supports that feature.
However we don't pass a head node pointer to mk_list_del function.
I think we need to seek the head node from a entry pointer or create a new API to pass a head node to decrement list size.
There was a problem hiding this comment.
That's true and the possible side effect could be a lot worse than the original issue, you're right.
|
Any updates or blockers at here? |
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
flb_mp_accessor_keys_remove expects incoming lists are sorted. Since it seeks shallow keys first. If it seeks nested key at first, it may fail to seek shallow key. Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
|
I rebased master and modified to use |
|
@edsiper @leonardo-albertovich |
|
@edsiper @leonardo-albertovich Ping. It is ready for review. |
|
@edsiper @leonardo-albertovich Ping. |
leonardo-albertovich
left a comment
There was a problem hiding this comment.
I don;'t see anything wrong with the code and considering it fixes a longstanding issue I think it should be merged ASAP.
src/flb_mp.c
Outdated
| mk_list_add(&ra->_head, &mpa->ra_list); | ||
|
|
||
| /* first time */ | ||
| if (mk_list_size(&mpa->ra_list) == 0) { |
There was a problem hiding this comment.
I think you could skip this block if becaise the mk_list_foreach in insert_by_subkey_num would not satisfy the condition in the for loop when the list is empty so it would skip straight to the mk_list_add fallback right?
There was a problem hiding this comment.
Thank you for reviewing. You are right.
I sent a following commit.
b98c063
| struct mk_list _head; /* Head to custom list (only used by flb_mp.h) */ | ||
| }; | ||
|
|
||
| int flb_ra_subkey_num(struct flb_record_accessor *ra); |
There was a problem hiding this comment.
Could you replace num with count everywhere? that would be much clearer.
There was a problem hiding this comment.
Thank you for reviewing.
I pushed following commit.
c9ece83
| int ret = -1; | ||
| int tmp; | ||
|
|
||
| if (ra == NULL) { |
There was a problem hiding this comment.
Maybe returning 0 in this case would be better even if that would make it undistinguishable from legitimate empty ra it would be it less error prone (ie. someone using a size_t without paying attention) since at the moment the result is not being checked.
There was a problem hiding this comment.
I prefer returning negative value.
In a future, the result can be checked.
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
Review comment: the mk_list_foreach in insert_by_subkey_num would not satisfy the condition in the for loop when the list is empty so it would skip straight to the mk_list_add fallback Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
|
CI failed, but I think it is not related this PR. |
|
thanks everyone! |
Fixes #5546
out_loki tries to remove key/value using flb_mp_accessor_keys_remove.
The API needs a key lists to indicate which key should be removed.
I tested the API and I found that the list should be sorted if it is passed nested key/value.
However the lists is not sorted at current master. It may not work if user passes nested key/value.
This patch is to fix it.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
Documentation
Backporting
Configuration
http_server.go:
Debug log
"kubernetes" field is removed.
Valgrind output
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.